var t = require("../../../@babel/runtime/helpers/typeof"), o = getApp();

Page({
    data: {
        language: "",
        data: [],
        bannerImgSrc: "",
        nextUrl: "",
        goodsID: "",
        signature: ""
    },
    onLoad: function(t) {
        this.checkrouter(), this.getjson();
    },
    checkrouter: function() {
        try {
            var o = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), o = t.popularize_page.mini.vue_route, e = 0; e < o.length; e++) if ("microShop_apply" == o[e]) return console.log(t.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === t(o)) return o.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getjson: function() {
        var t = this, e = o.getNetAddresss("plugin.micro.frontend.controllers.MicroShopApply.apply");
        o._getNetWork({
            url: e,
            success: function(o) {
                var e = o.data;
                1 == e.result && (t.setData({
                    nextUrl: e.data.create_order_api,
                    bannerImgSrc: e.data.micro_thumb,
                    data: e.data.levels,
                    signature: e.data.signature
                }), e.data.signature && wx.setStorage({
                    key: "reg_info",
                    data: e.data.signature
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    goodschange: function(t) {
        var o = t.detail;
        this.setData({
            goodsID: parseInt(o)
        });
    },
    open: function() {
        wx.navigateTo({
            url: "/packageC/microshop/microShop_apply_reg_info/microShop_apply_reg_info?"
        });
    },
    pay: function() {
        if (o._isTextEmpty(this.data.goodsID)) wx.showToast({
            icon: "none",
            title: "请选择店主等级",
            duration: 1500
        }); else {
            var t = this, e = o.getNetAddresss(this.data.nextUrl);
            e += "&goods_id=" + this.data.goodsID, e += "&total=1", o._getNetWork({
                url: e,
                success: function(o) {
                    var e = o.data;
                    1 == e.result ? wx.navigateTo({
                        url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&goodsId=" + t.data.goodsID + "&optionsId=&total=1"
                    }) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});